﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using PrinterBudi.Persistence;

namespace PrinterBudi.Desktop
{
    public partial class FormAddPBUser : Form
    {
        public FormAddPBUser()
        {
            InitializeComponent();
        }

        private void btnSubmit_Click(object sender, EventArgs e)
        {
            if (PBUserModel.Create(tbPhoneNumberUser.Text, tbPasswordUser.Text, tbNameUser.Text, tbAddressUser.Text, 0))
            {
                MessageBox.Show("Success!");
                this.Close();
            }
            else
            {
                if (PBUserModel.Read(tbPhoneNumberUser.Text) != null)
                    MessageBox.Show("User already exists!");
                else
                    MessageBox.Show("Failed!");
            }
           
        }

        private void btnClose_Click(object sender, EventArgs e)
        {
            this.Close();
        }

    }
}
